<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta name="generator" content="Doxygen 1.9.1"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>AIfES 2: ailayer Struct Reference</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="navtree.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="resize.js"></script>
<script type="text/javascript" src="navtreedata.js"></script>
<script type="text/javascript" src="navtree.js"></script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/searchdata.js"></script>
<script type="text/javascript" src="search/search.js"></script>
<script type="text/x-mathjax-config">
  MathJax.Hub.Config({
    extensions: ["tex2jax.js"],
    jax: ["input/TeX","output/HTML-CSS"],
});
</script>
<script type="text/javascript" async="async" src="https://cdn.jsdelivr.net/npm/mathjax@2/MathJax.js"></script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  <td id="projectlogo"><img alt="Logo" src="AIfES_logo_small.png"/></td>
  <td id="projectalign" style="padding-left: 0.5em;">
   <div id="projectname">AIfES 2
   &#160;<span id="projectnumber">2.0.0</span>
   </div>
  </td>
 </tr>
 </tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.9.1 -->
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */
var searchBox = new SearchBox("searchBox", "search",false,'Search','.html');
/* @license-end */
</script>
<script type="text/javascript" src="menudata.js"></script>
<script type="text/javascript" src="menu.js"></script>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */
$(function() {
  initMenu('',true,false,'search.php','Search');
  $(document).ready(function() { init_search(); });
});
/* @license-end */</script>
<div id="main-nav"></div>
</div><!-- top -->
<div id="side-nav" class="ui-resizable side-nav-resizable">
  <div id="nav-tree">
    <div id="nav-tree-contents">
      <div id="nav-sync" class="sync"></div>
    </div>
  </div>
  <div id="splitbar" style="-moz-user-select:none;" 
       class="ui-resizable-handle">
  </div>
</div>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */
$(document).ready(function(){initNavTree('structailayer.html',''); initResizable(); });
/* @license-end */
</script>
<div id="doc-content">
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
</div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0" 
        name="MSearchResults" id="MSearchResults">
</iframe>
</div>

<div class="header">
  <div class="summary">
<a href="#pub-attribs">Data Fields</a>  </div>
  <div class="headertitle">
<div class="title">ailayer Struct Reference</div>  </div>
</div><!--header-->
<div class="contents">

<p>AIfES layer interface.  
 <a href="structailayer.html#details">More...</a></p>

<p><code>#include &lt;<a class="el" href="aifes__core_8h_source.html">aifes_core.h</a>&gt;</code></p>
<table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="pub-attribs"></a>
Data Fields</h2></td></tr>
<tr class="memitem:a259a8d38509bfc89f5ff49b2a0d26b92"><td class="memItemLeft" align="right" valign="top"><a id="a259a8d38509bfc89f5ff49b2a0d26b92"></a>
const <a class="el" href="structaicore__layertype.html">aicore_layertype_t</a> *&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="structailayer.html#a259a8d38509bfc89f5ff49b2a0d26b92">layer_type</a></td></tr>
<tr class="memdesc:a259a8d38509bfc89f5ff49b2a0d26b92"><td class="mdescLeft">&#160;</td><td class="mdescRight">Type of the layer (for example ailayer_dense_type) <br /></td></tr>
<tr class="separator:a259a8d38509bfc89f5ff49b2a0d26b92"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a27d1eadee2654a2bd6e740eff4004ba8"><td class="memItemLeft" align="right" valign="top"><a id="a27d1eadee2654a2bd6e740eff4004ba8"></a>
void *&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="structailayer.html#a27d1eadee2654a2bd6e740eff4004ba8">layer_configuration</a></td></tr>
<tr class="memdesc:a27d1eadee2654a2bd6e740eff4004ba8"><td class="mdescLeft">&#160;</td><td class="mdescRight">Layer specific configurations (back-link from abstract layer class to implementation) <br /></td></tr>
<tr class="separator:a27d1eadee2654a2bd6e740eff4004ba8"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ac0da37622121ce424bfefdeaaf924508"><td class="memItemLeft" align="right" valign="top">uint32_t&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="structailayer.html#ac0da37622121ce424bfefdeaaf924508">settings</a></td></tr>
<tr class="memdesc:ac0da37622121ce424bfefdeaaf924508"><td class="mdescLeft">&#160;</td><td class="mdescRight">General layer settings like freezing weights or switching between training and evaluation mode.  <a href="structailayer.html#ac0da37622121ce424bfefdeaaf924508">More...</a><br /></td></tr>
<tr class="separator:ac0da37622121ce424bfefdeaaf924508"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a1ed86d1fec7aae68bc79c55f3f965790"><td class="memItemLeft" align="right" valign="top"><a id="a1ed86d1fec7aae68bc79c55f3f965790"></a>
<a class="el" href="structaitensor.html">aitensor_t</a>&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="structailayer.html#a1ed86d1fec7aae68bc79c55f3f965790">result</a></td></tr>
<tr class="memdesc:a1ed86d1fec7aae68bc79c55f3f965790"><td class="mdescLeft">&#160;</td><td class="mdescRight">The result of the forward function is stored here. <br /></td></tr>
<tr class="separator:a1ed86d1fec7aae68bc79c55f3f965790"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a66787e37cfd371070476221e86386f7c"><td class="memItemLeft" align="right" valign="top">void(*&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="structailayer.html#a66787e37cfd371070476221e86386f7c">calc_result_shape</a> )(<a class="el" href="structailayer.html">ailayer_t</a> *self)</td></tr>
<tr class="memdesc:a66787e37cfd371070476221e86386f7c"><td class="mdescLeft">&#160;</td><td class="mdescRight">Calculate and write the shape to the result tensor.  <a href="structailayer.html#a66787e37cfd371070476221e86386f7c">More...</a><br /></td></tr>
<tr class="separator:a66787e37cfd371070476221e86386f7c"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ab5e8fd65efe85a1ee1ac9147594ddd61"><td class="memItemLeft" align="right" valign="top">void(*&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="structailayer.html#ab5e8fd65efe85a1ee1ac9147594ddd61">calc_result_tensor_params</a> )(<a class="el" href="structailayer.html">ailayer_t</a> *self)</td></tr>
<tr class="memdesc:ab5e8fd65efe85a1ee1ac9147594ddd61"><td class="mdescLeft">&#160;</td><td class="mdescRight">If available, calculate and set the tensor_params of the result tensor.  <a href="structailayer.html#ab5e8fd65efe85a1ee1ac9147594ddd61">More...</a><br /></td></tr>
<tr class="separator:ab5e8fd65efe85a1ee1ac9147594ddd61"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a5fbd0ec6a416b01399233d98e60ca060"><td class="memItemLeft" align="right" valign="top">void(*&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="structailayer.html#a5fbd0ec6a416b01399233d98e60ca060">forward</a> )(<a class="el" href="structailayer.html">ailayer_t</a> *self)</td></tr>
<tr class="memdesc:a5fbd0ec6a416b01399233d98e60ca060"><td class="mdescLeft">&#160;</td><td class="mdescRight">Calculate the forward pass and write the result to the result tensor.  <a href="structailayer.html#a5fbd0ec6a416b01399233d98e60ca060">More...</a><br /></td></tr>
<tr class="separator:a5fbd0ec6a416b01399233d98e60ca060"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a6e0cd193754d9614d5da823f0f0fcbf6"><td class="memItemLeft" align="right" valign="top"><a id="a6e0cd193754d9614d5da823f0f0fcbf6"></a>
<a class="el" href="structaitensor.html">aitensor_t</a>&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="structailayer.html#a6e0cd193754d9614d5da823f0f0fcbf6">deltas</a></td></tr>
<tr class="memdesc:a6e0cd193754d9614d5da823f0f0fcbf6"><td class="mdescLeft">&#160;</td><td class="mdescRight">The result of the backward function is stored here. <br /></td></tr>
<tr class="separator:a6e0cd193754d9614d5da823f0f0fcbf6"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a235e06f76bc9641b9c9b95ae29b56fe9"><td class="memItemLeft" align="right" valign="top">void(*&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="structailayer.html#a235e06f76bc9641b9c9b95ae29b56fe9">backward</a> )(<a class="el" href="structailayer.html">ailayer_t</a> *self)</td></tr>
<tr class="memdesc:a235e06f76bc9641b9c9b95ae29b56fe9"><td class="mdescLeft">&#160;</td><td class="mdescRight">Calculate the backward pass and write the result to the deltas tensor.  <a href="structailayer.html#a235e06f76bc9641b9c9b95ae29b56fe9">More...</a><br /></td></tr>
<tr class="separator:a235e06f76bc9641b9c9b95ae29b56fe9"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr><td colspan="2"><div class="groupHeader">Layer connections</div></td></tr>
<tr><td colspan="2"><div class="groupText"><p>Defines the model graph. </p>
</div></td></tr>
<tr class="memitem:a708a94e69112ad215b2b52da2238a711"><td class="memItemLeft" align="right" valign="top"><a id="a708a94e69112ad215b2b52da2238a711"></a>
<a class="el" href="structailayer.html">ailayer_t</a> *&#160;</td><td class="memItemRight" valign="bottom"><b>input_layer</b></td></tr>
<tr class="separator:a708a94e69112ad215b2b52da2238a711"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a7c7ad89e7d15631b3f5893b8f19030ef"><td class="memItemLeft" align="right" valign="top"><a id="a7c7ad89e7d15631b3f5893b8f19030ef"></a>
<a class="el" href="structailayer.html">ailayer_t</a> *&#160;</td><td class="memItemRight" valign="bottom"><b>output_layer</b></td></tr>
<tr class="separator:a7c7ad89e7d15631b3f5893b8f19030ef"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr><td colspan="2"><div class="groupHeader">Inference and training scheduling order (Not in use yet)</div></td></tr>
<tr><td colspan="2"><div class="groupText"><p>The scheduler can execute the layers along this path. </p>
</div></td></tr>
<tr class="memitem:a47213b2dc55647e7c77da67e90efbe14"><td class="memItemLeft" align="right" valign="top"><a id="a47213b2dc55647e7c77da67e90efbe14"></a>
<a class="el" href="structailayer.html">ailayer_t</a> *&#160;</td><td class="memItemRight" valign="bottom"><b>next_scheduled</b></td></tr>
<tr class="separator:a47213b2dc55647e7c77da67e90efbe14"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a966bd2917b6b8822e40467269cc30ce4"><td class="memItemLeft" align="right" valign="top"><a id="a966bd2917b6b8822e40467269cc30ce4"></a>
<a class="el" href="structailayer.html">ailayer_t</a> *&#160;</td><td class="memItemRight" valign="bottom"><b>prev_scheduled</b></td></tr>
<tr class="separator:a966bd2917b6b8822e40467269cc30ce4"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr><td colspan="2"><div class="groupHeader">Training memory API</div></td></tr>
<tr><td colspan="2"><div class="groupText"><p>Makes the memory of the trainable params, the gradients and optimizer stuff accessible.</p>
<p>This is used, for example, for the optimiser or debugging purposes. </p>
</div></td></tr>
<tr class="memitem:a328cb32bcb611f02ace7da86ab9711a2"><td class="memItemLeft" align="right" valign="top"><a id="a328cb32bcb611f02ace7da86ab9711a2"></a>
uint8_t&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="structailayer.html#a328cb32bcb611f02ace7da86ab9711a2">trainable_params_count</a></td></tr>
<tr class="memdesc:a328cb32bcb611f02ace7da86ab9711a2"><td class="mdescLeft">&#160;</td><td class="mdescRight">Number of trainable parameter tensors. <br /></td></tr>
<tr class="separator:a328cb32bcb611f02ace7da86ab9711a2"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a8a3410d74de23e53ffb75649fec0851a"><td class="memItemLeft" align="right" valign="top"><a id="a8a3410d74de23e53ffb75649fec0851a"></a>
<a class="el" href="structaitensor.html">aitensor_t</a> **&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="structailayer.html#a8a3410d74de23e53ffb75649fec0851a">trainable_params</a></td></tr>
<tr class="memdesc:a8a3410d74de23e53ffb75649fec0851a"><td class="mdescLeft">&#160;</td><td class="mdescRight">Array of tensor pointers with length trainable_params_count. <br /></td></tr>
<tr class="separator:a8a3410d74de23e53ffb75649fec0851a"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:adf565818ce1d94c39e818326a25a6de8"><td class="memItemLeft" align="right" valign="top"><a id="adf565818ce1d94c39e818326a25a6de8"></a>
<a class="el" href="structaitensor.html">aitensor_t</a> **&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="structailayer.html#adf565818ce1d94c39e818326a25a6de8">gradients</a></td></tr>
<tr class="memdesc:adf565818ce1d94c39e818326a25a6de8"><td class="mdescLeft">&#160;</td><td class="mdescRight">Array of tensor pointers with length trainable_params_count. <br /></td></tr>
<tr class="separator:adf565818ce1d94c39e818326a25a6de8"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a0d7d5229bb3c514d7bd3e2bcf40c5f5a"><td class="memItemLeft" align="right" valign="top"><a id="a0d7d5229bb3c514d7bd3e2bcf40c5f5a"></a>
void **&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="structailayer.html#a0d7d5229bb3c514d7bd3e2bcf40c5f5a">optimem</a></td></tr>
<tr class="memdesc:a0d7d5229bb3c514d7bd3e2bcf40c5f5a"><td class="mdescLeft">&#160;</td><td class="mdescRight">Array of memory pointers with length trainable_params_count. <br /></td></tr>
<tr class="separator:a0d7d5229bb3c514d7bd3e2bcf40c5f5a"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr><td colspan="2"><div class="groupHeader">Parameter memory</div></td></tr>
<tr><td colspan="2"><div class="groupText"><p>Calculate the size and set the memory for the parameter.</p>
<p>This memory (for example for weights, bias, ...) will last through all the lifetime of the model.<br  />
This is only intended for training when no initial weights are available. If the parameters are already known, set the parameter directly to the layer. </p>
</div></td></tr>
<tr class="memitem:ab758b2be3966c7cc0bf6920a60886bbf"><td class="memItemLeft" align="right" valign="top"><a id="ab758b2be3966c7cc0bf6920a60886bbf"></a>
uint32_t(*&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="structailayer.html#ab758b2be3966c7cc0bf6920a60886bbf">sizeof_paramem</a> )(const <a class="el" href="structailayer.html">ailayer_t</a> *self)</td></tr>
<tr class="memdesc:ab758b2be3966c7cc0bf6920a60886bbf"><td class="mdescLeft">&#160;</td><td class="mdescRight">Size of required memory (in bytes). <br /></td></tr>
<tr class="separator:ab758b2be3966c7cc0bf6920a60886bbf"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a219921bd3b75e98894a33f6c2ff61c07"><td class="memItemLeft" align="right" valign="top"><a id="a219921bd3b75e98894a33f6c2ff61c07"></a>
void(*&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="structailayer.html#a219921bd3b75e98894a33f6c2ff61c07">set_paramem</a> )(<a class="el" href="structailayer.html">ailayer_t</a> *self, void *memory_ptr)</td></tr>
<tr class="memdesc:a219921bd3b75e98894a33f6c2ff61c07"><td class="mdescLeft">&#160;</td><td class="mdescRight">Set and distribute the memory block internally. <br /></td></tr>
<tr class="separator:a219921bd3b75e98894a33f6c2ff61c07"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:aedac95cb35a037d0e513ac690c34681a"><td class="memItemLeft" align="right" valign="top"><a id="aedac95cb35a037d0e513ac690c34681a"></a>
void(*&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="structailayer.html#aedac95cb35a037d0e513ac690c34681a">init_params</a> )(<a class="el" href="structailayer.html">ailayer_t</a> *self)</td></tr>
<tr class="memdesc:aedac95cb35a037d0e513ac690c34681a"><td class="mdescLeft">&#160;</td><td class="mdescRight">Initialize the (trainable and not trainable) parameters of the layer with default initializers. <br /></td></tr>
<tr class="separator:aedac95cb35a037d0e513ac690c34681a"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr><td colspan="2"><div class="groupHeader">Temporary memory for forward and backward pass</div></td></tr>
<tr><td colspan="2"><div class="groupText"><p>Calculate the size of the required memory for temporary result in forward and backward pass </p>
</div></td></tr>
<tr class="memitem:adad0c59ab4a340940e6eb6a57f702b42"><td class="memItemLeft" align="right" valign="top"><a id="adad0c59ab4a340940e6eb6a57f702b42"></a>
uint32_t(*&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="structailayer.html#adad0c59ab4a340940e6eb6a57f702b42">sizeof_fwdmem</a> )(const <a class="el" href="structailayer.html">ailayer_t</a> *self)</td></tr>
<tr class="memdesc:adad0c59ab4a340940e6eb6a57f702b42"><td class="mdescLeft">&#160;</td><td class="mdescRight">Size of required memory for the forward pass (in bytes). <br /></td></tr>
<tr class="separator:adad0c59ab4a340940e6eb6a57f702b42"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:aa82f1f4092a60d30090d4e519b02d98d"><td class="memItemLeft" align="right" valign="top"><a id="aa82f1f4092a60d30090d4e519b02d98d"></a>
uint32_t(*&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="structailayer.html#aa82f1f4092a60d30090d4e519b02d98d">sizeof_bwdmem</a> )(const <a class="el" href="structailayer.html">ailayer_t</a> *self)</td></tr>
<tr class="memdesc:aa82f1f4092a60d30090d4e519b02d98d"><td class="mdescLeft">&#160;</td><td class="mdescRight">Size of required memory for the backward pass (in bytes). <br /></td></tr>
<tr class="separator:aa82f1f4092a60d30090d4e519b02d98d"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a5b6e01700671b0cb2118edd432b09a76"><td class="memItemLeft" align="right" valign="top"><a id="a5b6e01700671b0cb2118edd432b09a76"></a>
void *&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="structailayer.html#a5b6e01700671b0cb2118edd432b09a76">tempmem</a></td></tr>
<tr class="memdesc:a5b6e01700671b0cb2118edd432b09a76"><td class="mdescLeft">&#160;</td><td class="mdescRight">Pointer to the memory for the forward pass, backward pass and the optimizer. <br /></td></tr>
<tr class="separator:a5b6e01700671b0cb2118edd432b09a76"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr><td colspan="2"><div class="groupHeader">Training memory</div></td></tr>
<tr><td colspan="2"><div class="groupText"><p>Calculate the size and set the working memory for the training</p>
<p>This memory (for example for gradients, momentums, ...) is needed during the whole training process. If the training is finished, it can be deleted. </p>
</div></td></tr>
<tr class="memitem:af95ecd0e925bff73b30b1d1b6fc21028"><td class="memItemLeft" align="right" valign="top"><a id="af95ecd0e925bff73b30b1d1b6fc21028"></a>
uint32_t(*&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="structailayer.html#af95ecd0e925bff73b30b1d1b6fc21028">sizeof_trainmem</a> )(const <a class="el" href="structailayer.html">ailayer_t</a> *self)</td></tr>
<tr class="memdesc:af95ecd0e925bff73b30b1d1b6fc21028"><td class="mdescLeft">&#160;</td><td class="mdescRight">Size of required memory (in bytes). <br /></td></tr>
<tr class="separator:af95ecd0e925bff73b30b1d1b6fc21028"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a5062b6bf991a3ae278941c560847eeb6"><td class="memItemLeft" align="right" valign="top"><a id="a5062b6bf991a3ae278941c560847eeb6"></a>
void(*&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="structailayer.html#a5062b6bf991a3ae278941c560847eeb6">set_trainmem</a> )(<a class="el" href="structailayer.html">ailayer_t</a> *self, void *memory_ptr)</td></tr>
<tr class="memdesc:a5062b6bf991a3ae278941c560847eeb6"><td class="mdescLeft">&#160;</td><td class="mdescRight">Set and distribute the memory block internally. <br /></td></tr>
<tr class="separator:a5062b6bf991a3ae278941c560847eeb6"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table>
<a name="details" id="details"></a><h2 class="groupheader">Detailed Description</h2>
<div class="textblock"><p>AIfES layer interface. </p>
<div class="image">
<img src="ailayer.png" alt="" width="200px"/>
</div>
<p>The interface contains the necessary functions and parameters for inference and training on the model. (Refer to <a class="el" href="aifes__core_8h.html" title="AIfES 2 core interface.">aifes_core.h</a> for a structural overview)</p>
<p>The call order of the functions for inference:<br  />
</p><div class="fragment"><div class="line"><span class="keywordflow">for each</span> layer in the model</div>
<div class="line">    <a class="code" href="structailayer.html#a66787e37cfd371070476221e86386f7c">calc_result_shape</a>()</div>
<div class="line">endfor</div>
<div class="line"> </div>
<div class="line">for each layer in the model</div>
<div class="line">    <a class="code" href="structailayer.html#a5fbd0ec6a416b01399233d98e60ca060">forward</a>()</div>
<div class="line">endfor</div>
<div class="line"><span class="comment">// The result of the inference is now in output_layer.result tensor</span></div>
<div class="ttc" id="astructailayer_html_a5fbd0ec6a416b01399233d98e60ca060"><div class="ttname"><a href="structailayer.html#a5fbd0ec6a416b01399233d98e60ca060">ailayer::forward</a></div><div class="ttdeci">void(* forward)(ailayer_t *self)</div><div class="ttdoc">Calculate the forward pass and write the result to the result tensor.</div><div class="ttdef"><b>Definition:</b> aifes_core.h:315</div></div>
<div class="ttc" id="astructailayer_html_a66787e37cfd371070476221e86386f7c"><div class="ttname"><a href="structailayer.html#a66787e37cfd371070476221e86386f7c">ailayer::calc_result_shape</a></div><div class="ttdeci">void(* calc_result_shape)(ailayer_t *self)</div><div class="ttdoc">Calculate and write the shape to the result tensor.</div><div class="ttdef"><b>Definition:</b> aifes_core.h:300</div></div>
</div><!-- fragment --><p>The call order of the functions for training:<br  />
</p><div class="fragment"><div class="line"><span class="keywordflow">for each</span> layer in the model</div>
<div class="line">    <a class="code" href="structailayer.html#a66787e37cfd371070476221e86386f7c">calc_result_shape</a>()</div>
<div class="line">endfor</div>
<div class="line"> </div>
<div class="line"><span class="comment">// If the parameters are not already pretrained, a new parameter memory block can be created</span></div>
<div class="line">for each layer in the model</div>
<div class="line">    allocate memory of size <a class="code" href="structailayer.html#ab758b2be3966c7cc0bf6920a60886bbf">sizeof_paramem</a>()</div>
<div class="line">    <a class="code" href="structailayer.html#a219921bd3b75e98894a33f6c2ff61c07">set_paramem</a>()</div>
<div class="line">endfor</div>
<div class="line">init_trainable_parameters_model() <span class="comment">// Do some weight initialization</span></div>
<div class="line"> </div>
<div class="line">for each layer in the model</div>
<div class="line">    allocate memory of size <a class="code" href="structailayer.html#af95ecd0e925bff73b30b1d1b6fc21028">sizeof_trainmem</a>()</div>
<div class="line">    <a class="code" href="structailayer.html#a5062b6bf991a3ae278941c560847eeb6">set_trainmem</a>()</div>
<div class="line">endfor</div>
<div class="line"> </div>
<div class="line">init_trainmem_model() <span class="comment">// For example set the optimem to zero</span></div>
<div class="line">for iterations</div>
<div class="line">    for each batch in dataset</div>
<div class="line">        zero_gradients_model()</div>
<div class="line"> </div>
<div class="line">        for each sample in the batch</div>
<div class="line">            for each layer in the model</div>
<div class="line">                <a class="code" href="structailayer.html#a5fbd0ec6a416b01399233d98e60ca060">forward</a>()</div>
<div class="line">            endfor</div>
<div class="line"> </div>
<div class="line">            calc_delta()</div>
<div class="line">            for each layer in the model (reverse)</div>
<div class="line">                <a class="code" href="structailayer.html#a235e06f76bc9641b9c9b95ae29b56fe9">backward</a>()</div>
<div class="line">            endfor</div>
<div class="line">        endfor</div>
<div class="line"> </div>
<div class="line">        update_params_model()</div>
<div class="line">    endfor</div>
<div class="line">endfor</div>
<div class="ttc" id="astructailayer_html_a219921bd3b75e98894a33f6c2ff61c07"><div class="ttname"><a href="structailayer.html#a219921bd3b75e98894a33f6c2ff61c07">ailayer::set_paramem</a></div><div class="ttdeci">void(* set_paramem)(ailayer_t *self, void *memory_ptr)</div><div class="ttdoc">Set and distribute the memory block internally.</div><div class="ttdef"><b>Definition:</b> aifes_core.h:352</div></div>
<div class="ttc" id="astructailayer_html_a235e06f76bc9641b9c9b95ae29b56fe9"><div class="ttname"><a href="structailayer.html#a235e06f76bc9641b9c9b95ae29b56fe9">ailayer::backward</a></div><div class="ttdeci">void(* backward)(ailayer_t *self)</div><div class="ttdoc">Calculate the backward pass and write the result to the deltas tensor.</div><div class="ttdef"><b>Definition:</b> aifes_core.h:341</div></div>
<div class="ttc" id="astructailayer_html_a5062b6bf991a3ae278941c560847eeb6"><div class="ttname"><a href="structailayer.html#a5062b6bf991a3ae278941c560847eeb6">ailayer::set_trainmem</a></div><div class="ttdeci">void(* set_trainmem)(ailayer_t *self, void *memory_ptr)</div><div class="ttdoc">Set and distribute the memory block internally.</div><div class="ttdef"><b>Definition:</b> aifes_core.h:373</div></div>
<div class="ttc" id="astructailayer_html_ab758b2be3966c7cc0bf6920a60886bbf"><div class="ttname"><a href="structailayer.html#ab758b2be3966c7cc0bf6920a60886bbf">ailayer::sizeof_paramem</a></div><div class="ttdeci">uint32_t(* sizeof_paramem)(const ailayer_t *self)</div><div class="ttdoc">Size of required memory (in bytes).</div><div class="ttdef"><b>Definition:</b> aifes_core.h:351</div></div>
<div class="ttc" id="astructailayer_html_af95ecd0e925bff73b30b1d1b6fc21028"><div class="ttname"><a href="structailayer.html#af95ecd0e925bff73b30b1d1b6fc21028">ailayer::sizeof_trainmem</a></div><div class="ttdeci">uint32_t(* sizeof_trainmem)(const ailayer_t *self)</div><div class="ttdoc">Size of required memory (in bytes).</div><div class="ttdef"><b>Definition:</b> aifes_core.h:372</div></div>
</div><!-- fragment --> </div><h2 class="groupheader">Field Documentation</h2>
<a id="a235e06f76bc9641b9c9b95ae29b56fe9"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a235e06f76bc9641b9c9b95ae29b56fe9">&#9670;&nbsp;</a></span>backward</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void(* backward) (<a class="el" href="structailayer.html">ailayer_t</a> *self)</td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Calculate the backward pass and write the result to the deltas tensor. </p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">self</td><td>The layer </td></tr>
  </table>
  </dd>
</dl>

</div>
</div>
<a id="a66787e37cfd371070476221e86386f7c"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a66787e37cfd371070476221e86386f7c">&#9670;&nbsp;</a></span>calc_result_shape</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void(* calc_result_shape) (<a class="el" href="structailayer.html">ailayer_t</a> *self)</td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Calculate and write the shape to the result tensor. </p>
<p>Made for easy creation of the model (layers can be connected to each other without worrying about the shapes).</p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">self</td><td>The layer </td></tr>
  </table>
  </dd>
</dl>

</div>
</div>
<a id="ab5e8fd65efe85a1ee1ac9147594ddd61"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ab5e8fd65efe85a1ee1ac9147594ddd61">&#9670;&nbsp;</a></span>calc_result_tensor_params</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void(* calc_result_tensor_params) (<a class="el" href="structailayer.html">ailayer_t</a> *self)</td>
        </tr>
      </table>
</div><div class="memdoc">

<p>If available, calculate and set the tensor_params of the result tensor. </p>
<p>Some layers (like some activation functions) have pre-defined tensor_params that can be set to the result tensor with this function. Set this function to 0 if the tensor_params calculation is not trivial (e.g. dependent on input data).</p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">self</td><td>The layer </td></tr>
  </table>
  </dd>
</dl>

</div>
</div>
<a id="a5fbd0ec6a416b01399233d98e60ca060"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a5fbd0ec6a416b01399233d98e60ca060">&#9670;&nbsp;</a></span>forward</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void(* forward) (<a class="el" href="structailayer.html">ailayer_t</a> *self)</td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Calculate the forward pass and write the result to the result tensor. </p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">self</td><td>The layer </td></tr>
  </table>
  </dd>
</dl>

</div>
</div>
<a id="ac0da37622121ce424bfefdeaaf924508"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ac0da37622121ce424bfefdeaaf924508">&#9670;&nbsp;</a></span>settings</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">uint32_t settings</td>
        </tr>
      </table>
</div><div class="memdoc">

<p>General layer settings like freezing weights or switching between training and evaluation mode. </p>
<p><b>Example:</b> Read a value from the settings </p><div class="fragment"><div class="line"><span class="keywordflow">if</span>(AILAYER_SETTINGS_IS(layer-&gt;settings, 0b1, AILAYER_SETTINGS_TRAINABLE)){</div>
<div class="line">  ...</div>
<div class="line">}</div>
</div><!-- fragment --><p><b>Example:</b> Write a value to the settings </p><div class="fragment"><div class="line">AILAYER_SETTINGS_SET(layer-&gt;settings, 0b1, AILAYER_SETTINGS_TRAINABLE, FALSE);</div>
</div><!-- fragment --><p> General layer settings like freezing weights or switching between training and evaluation mode. </p>

</div>
</div>
<hr/>The documentation for this struct was generated from the following file:<ul>
<li><a class="el" href="aifes__core_8h_source.html">aifes_core.h</a></li>
</ul>
</div><!-- contents -->
</div><!-- doc-content -->
<!-- start footer part -->
<div id="nav-path" class="navpath"><!-- id is needed for treeview function! -->
  <ul>
    <li class="navelem"><a class="el" href="structailayer.html">ailayer</a></li>
    <li class="footer">Generated by <a href="https://www.doxygen.org/index.html"><img class="footer" src="doxygen.svg" width="104" height="31" alt="doxygen"/></a> 1.9.1 </li>
  </ul>
</div>
</body>
</html>
